/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package serwer;

import java.net.Socket;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;

/**
 *
 * @author Marcin
 */
public class CList {
    private Map mapa = new HashMap();
    private Map mapb = new HashMap();
    private int ID=0;
    
    public boolean isMsg(int ID){
        if((boolean)mapa.get(ID)){
            if(!((Queue)mapb.get(ID)).isEmpty()){
                return true;
            }
        }
          return false;
    }
    
    public int connect(){
        mapa.put(ID, true);
        mapb.put(ID, (Queue)(new LinkedList()));
        return ID++;
    }
    public void disconnect(int ID){
        mapa.put(ID, false);
        mapb.put(ID, null);
    }
    
    public String getMsg(int ID){
        return (String)((Queue)mapb.get(ID)).remove();
    }
}
